package com.example.smartlearning.controller;

import com.example.smartlearning.service.impl.CollectionServiceImpl;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

@CrossOrigin//跨域
@RestController//遵循RestFul
@RequestMapping("/Smart/Collection/")
public class CollectionController {

    @Resource
    CollectionServiceImpl collectionService;

    /**
     * 获取收藏
     *
     * @param userId 用户id
     * @return 返回
     */
    @GetMapping("getCollection")
    public String getCollection(@RequestParam("userId") int userId) {
        return collectionService.getCollection(userId);
    }

    /**
     * 添加收藏接口
     * @param userId   用户id
     * @param lessonId 课程id
     * @return 返回
     */
    @PostMapping("addCollection")
    public String addCollection(@RequestParam("userId") int userId, @RequestParam("lessonId") int lessonId) {
        return collectionService.addCollection(userId, lessonId);
    }

    /**
     * 取消收藏接口
     *
     * @param collectionId 收藏id
     * @return 返回
     */
    @PostMapping("cancelCollection")
    public String cancelCollection(@RequestParam("collectionId") int collectionId) {
        return collectionService.cancelCollection(collectionId);
    }



}
